package com.example.graduatetest.activitys;

import androidx.appcompat.app.ActionBar;
import androidx.appcompat.app.AppCompatActivity;
import androidx.databinding.DataBindingUtil;
import androidx.lifecycle.ViewModelProviders;

import android.content.Intent;
import android.net.NetworkInfo;
import android.os.Bundle;

import com.example.graduatetest.R;
import com.example.graduatetest.bean.Card;
import com.example.graduatetest.bean.Classes;
import com.example.graduatetest.databinding.ActivityCardDetailBinding;
import com.example.graduatetest.view.model.CardDetailViewModel;
import com.example.graduatetest.view.model.ChangePasswordViewModel;

public class CardDetailActivity extends AppCompatActivity {
    private ActivityCardDetailBinding binding;
    private CardDetailViewModel detailViewModel;
    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_card_detail);
        //隐藏ActionBar
        if(getSupportActionBar() != null){
            ActionBar actionBar = getSupportActionBar();
            actionBar.hide();
        }
        binding = DataBindingUtil.setContentView(this,R.layout.activity_card_detail);

        //接受Intent传来的数据
        Intent intent = getIntent();
        Card ownCard = (Card) intent.getSerializableExtra("card");

        //LiveData
        detailViewModel = ViewModelProviders.of(this).get(CardDetailViewModel.class);
        binding.setCardDetailViewModel(detailViewModel);
        binding.setLifecycleOwner(this);
        detailViewModel.init(this,binding,ownCard);
    }
}
